<?php
/***************************************************************************
 * 
 * Copyright (c) 2010 , Inc. All Rights Reserved
 * $Id$ 
 * 
 **************************************************************************/
 
 
 
/**
 * @file ValidationFloatTest.php
 * @author niulei(niulei@)
 * @date 2010/05/17 18:58:28
 * @version $Revision$ 
 * @brief 
 *  
 **/
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'validate/Validation.php';

class ValidationArrayInputTest extends PHPUnit_Framework_TestCase{

    protected function setUp()
    {			
       sleep(1);
    }
    
    public function testArrayInput(){
    	$arr_input = array(
    	                     'u_telno' => '0555-93833',
    	                     'u_idnum' => '342529029383123456',
    	                     'u_birth' => '2009-08-32',
    	                     'u_int'   => 12,
    	                     'u_float' => 12.33,
    	                     'u_string' => "hello world",    	
    	                   );
    	$arr_rules = array(
    	                    'u_telno' => array(
    	                                        'func' => 'TELNO',
    	                                        'flag' => 'FLAG_ALLOW_EMPTY',
    	                                       ),
    	                    'u_idnum' => array(
    	                                        'func' => 'IDNUM',
    	                                       ),                
    	                    'u_birth' => array(
    	                                        'func' => 'BIRTH',
    	                                       ),  
    	                    'u_float' => array(
    	                                        'func' => 'FLOAT',
    	                                        'flag' => 'FLAG_ALLOW_EMPTY',
    	                                        'min_range'=>0.99,//最小
                                                'max_range'=>100.99,//最大
                                                'decimal'=>3,
    	                                       ), 
    	                    'u_string' => array(
    	                                        'func' => 'STRING_SINGLE',
    	                                        'flag' => 'FLAG_ALLOW_EMPTY',
    	                                        'min_range'=>1,//最小
                                                'max_range'=>2,//最大
    	                                       ),     	                     
    	                   );
    	$arr_check_res = Validation::checkArray($arr_input, $arr_rules);
        $this->assertEquals(6, count($arr_check_res));
        $this->assertTrue($arr_check_res['u_int']);
        $this->assertTrue($arr_check_res['u_telno']);
        $this->assertTrue($arr_check_res['u_float']);
        $this->assertContains("Length checked", $arr_check_res['u_string']);
        $this->assertContains("Content checked", $arr_check_res['u_idnum']);
        $this->assertContains("Content checked", $arr_check_res['u_birth']);
    } 
}
?>
